package com.tt.fashionWebSite.controller;

import com.tt.fashionWebSite.dto.*;
import com.tt.fashionWebSite.service.Ad_RuleService;
import com.tt.fashionWebSite.service.ReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.text.ParseException;
import java.util.List;

/**
 * Created by isoft-work 5 on 1/17/2015.
 */
@Controller
public class Ad_ReportController {
   @Autowired
   private ReportService reportService;

   @RequestMapping(value = "/admin/report/getNumberRemainProduct/", method = RequestMethod.GET)
   public @ResponseBody
   JsonResponseDto<List<RemainProductReportDto>> getNumberRemainProduct(HttpServletRequest request) throws ParseException {
      return new JsonResponseDto<List<RemainProductReportDto>>(reportService.getNumberRemainProduct(), JsonResponseCode.SUCCESS);
   }

   @RequestMapping(value = "/admin/report/getNumberSellProductForMonth/{date}", method = RequestMethod.GET)
   public @ResponseBody
   JsonResponseDto<List<RevenueDateAndSellMonthReportDto>> getNumberSellProductForMonth(HttpServletRequest request, @PathVariable String date) throws ParseException {
      return new JsonResponseDto<List<RevenueDateAndSellMonthReportDto>>(reportService.getNumberSellProductForMonth(date), JsonResponseCode.SUCCESS);
   }

   @RequestMapping(value = "/admin/report/getNumberSaleProduct/", method = RequestMethod.GET)
   public @ResponseBody
   JsonResponseDto<List<SaleProductReportDto>> getNumberSaleProduct(HttpServletRequest request) throws ParseException {
      return new JsonResponseDto<List<SaleProductReportDto>>(reportService.getNumberSaleProduct(), JsonResponseCode.SUCCESS);
   }

   @RequestMapping(value = "/admin/report/getRevenueForDate/{date}", method = RequestMethod.GET)
   public @ResponseBody
   JsonResponseDto<List<RevenueDateAndSellMonthReportDto>> getRevenueForDate(HttpServletRequest request, @PathVariable String date) throws ParseException {
      return new JsonResponseDto<List<RevenueDateAndSellMonthReportDto>>(reportService.getRevenueForDate(date), JsonResponseCode.SUCCESS);
   }

   @RequestMapping(value = "/admin/report/getRevenueForMonth/{date}", method = RequestMethod.GET)
   public @ResponseBody
   JsonResponseDto<List<RevenueMonthReportDto>> getRevenueForMonth(HttpServletRequest request, @PathVariable String date) throws ParseException {
      return new JsonResponseDto<List<RevenueMonthReportDto>>(reportService.getRevenueForMonth(date), JsonResponseCode.SUCCESS);
   }

   @RequestMapping(value = "/admin/report/getRevenueForQuarterly/{date}", method = RequestMethod.GET)
   public @ResponseBody
   JsonResponseDto<List<RevenueQuarterlyReportDto>> getRevenueForQuarterly(HttpServletRequest request, @PathVariable String date) throws ParseException {
      return new JsonResponseDto<List<RevenueQuarterlyReportDto>>(reportService.getRevenueForQuarterly(date), JsonResponseCode.SUCCESS);
   }

   @RequestMapping(value = "/admin/report/getRevenueBuyOfUser/{date}", method = RequestMethod.GET)
   public @ResponseBody
   JsonResponseDto<List<BuyUserReportDto>> getRevenueBuyOfUser(HttpServletRequest request, @PathVariable String date) throws ParseException {
      return new JsonResponseDto<List<BuyUserReportDto>>(reportService.getRevenueBuyOfUser(date), JsonResponseCode.SUCCESS);
   }
}
